<template>
    <section class="section section-shaped section-lg my-0">
        <div class="shape shape-style-1 bg-gradient-default">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
        <div class="container pt-lg-md">
            <div class="row justify-content-center">
                <div class="col-lg-12">
                    <card type="secondary" shadow
                          header-classes="bg-white pb-5"
                          body-classes="px-lg-5 py-lg-5"
                          class="border-0">
                         <div v-if="showInfo" class="contentDiv">
                        <base-alert class="col-md-6" type="dark">
                                {{infoMsg}}
                            </base-alert>
                        </div>
                        <adminOrder v-for="(result,index) in results" :key="index" :msg="result"></adminOrder>
                        <!--<div class="row justify-content-center">
                            <div class="col-md-12">
                                <div class="row mb-3">
                                    <strong class="col-md-4" style="text-align:right">房源名称：</strong>
                                    <a href="#"><strong class="col-md-8" style="text-align:left">时尚花园 全新家电 可短租 带独立阳台 上班方便</strong></a>
                                </div>
                                <div class="row mb-3">
                                    <strong class="col-md-4" style="text-align:right">
                                        用户名称：
                                    </strong>
                                    <a href="#"><strong class="col-md-8" style="text-align:left"></strong></a>
                                </div>
                                <div class="row mb-3">
                                    <p class="col-md-4" style="text-align:right">
                                        租赁时间：
                                    </p>
                                    <a href="#"><p class="col-md-8" style="text-align:left"></p></a>
                                </div>
                                <div class="row mb-3 justify-content-center">
                                    <badge v-if="waitAudit" type="warning">待审核</badge>
                                    <badge v-if="Audit" type="success">审核通过</badge>
                                    <badge v-if="!Audit" type="danger">审核失败</badge>
                                    <badge v-if="close && isAudit" type="danger">交易关闭</badge>
                                </div>
                                <div class="row justify-content-center">
                                    <base-button @click="updateStatus('pass')" v-if="!isAudit" type="success">通过</base-button>
                                    <base-button @click="updateStatus('refuse')" v-if="!isAudit" type="danger">拒绝</base-button>
                                    <base-button v-if="isAudit" type="danger">关闭交易</base-button>
                                </div>
                            </div>
                        </div>
                        <hr>
                        <div class="row justify-content-center">
                            <div class="col-md-12">
                                <div class="row mb-3">
                                    <strong class="col-md-4" style="text-align:right">房源名称：</strong>
                                    <a href="#"><strong class="col-md-8" style="text-align:left">时尚花园 全新家电 可短租 带独立阳台 上班方便</strong></a>
                                </div>
                                <div class="row mb-3">
                                    <strong class="col-md-4" style="text-align:right">
                                        用户名称：
                                    </strong>
                                    <a href="#"><strong class="col-md-8" style="text-align:left"></strong></a>
                                </div>
                                <div class="row mb-3">
                                    <p class="col-md-4" style="text-align:right">
                                        租赁时间：
                                    </p>
                                    <a href="#"><p class="col-md-8" style="text-align:left"></p></a>
                                </div>
                                <div class="row mb-3 justify-content-center">
                                    <badge v-if="waitAudit" type="warning">待审核</badge>
                                    <badge v-if="Audit" type="success">审核通过</badge>
                                    <badge v-if="!Audit" type="danger">审核失败</badge>
                                    <badge v-if="close && isAudit" type="danger">交易关闭</badge>
                                </div>
                                <div class="row justify-content-center">
                                    <base-button v-if="!isAudit" type="success">通过</base-button>
                                    <base-button v-if="!isAudit" type="danger">拒绝</base-button>
                                    <base-button v-if="isAudit" type="danger">关闭交易</base-button>
                                </div>
                            </div>
                        </div>-->
                    </card>
                </div>
            </div>
        </div>
    </section>
</template>
<script>
import adminOrder from "./components/adminOrder";
import {getApplicationToSolve} from "../api";
export default {
    data() {
        return{
            results: [],
            isAudit:false,
            Audit:true,
            close:true,
            paid:true,
            processing:true,
            processed:false,
        }
    },
    methods: {
        getHouseList(){
                this.showError = this.showInfo = false;
                getApplicationToSolve()
                    .then(res => {
                        this.results = res.data;
                        if (this.results === null || this.results.length === 0){
                            this.showInfo = true;
                            this.infoMsg = '没有订单需要处理';
                        }
                    })
                    .catch(err => {
                        this.$router.push({name: 'login'});
                    })
            }
        },
     watch: {
            "$route": "getHouseList"
        },
        created(){
            this.getHouseList();
        },
        components: {
            adminOrder
        }
};
</script>
<style>
.contentDiv{
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    margin: auto;
}
</style>
